<div class="col-md-9">
  <div class="thumbnail"> 
    <!-- breadcrumb -->
    <ol class="breadcrumb breadcrumb-arrow">
      <li><a href="{:U(GROUP_NAME . '/Rbac')}">RBAC</a></li>
      <li class="active"><span>角色列表</span></li>
    </ol>

    <table class="table">
      <caption><h3>角色列表</h3></caption>
      <thead>
        <tr>
          <th>ID</th>
          <th>角色名称</th>
          <th>角色描述</th>
          <th>开启状态</th>
          <th>操作</th>
          <th>删除</th>
        </tr>
      </thead>
      <tbody>
        <volist name="role" id="r">
          <tr>
            <td>{$r.id}</td>
            <td>{$r.name}</td>
            <td>{$r.remark}</td>
            <td>
              <if condition="$r['status']"> 开启
                <else /> 关闭
              </if>
            </td>
            <td>
              <a href="{:U(GROUP_NAME . '/Rbac/access', array('id' => $r['id']))}" class="btn btn-info">配置权限</a>
            </td>
            <td>
              <input type="button" class="btn btn-danger" value="删除角色" onclick="delRole({$r['id']})">
            </td>
          </tr>
        </volist>
        
      </tbody>
    </table>
  </div>
</div>

<script>
  function delRole (id) {
    // 动态生成一个form
    var delForm = document.createElement("FORM");
    document.body.appendChild(delForm);
    delForm.method = "POST";
    delForm.action = "{:U(GROUP_NAME . '/Rbac/delRole')}";
    // 添加一个hidden标签用来记录p_id
    var hiddenInput1 = document.createElement("input");
    hiddenInput1.setAttribute("name", "id");
    hiddenInput1.setAttribute("type","hidden");
    hiddenInput1.setAttribute("value",id);
    delForm.appendChild(hiddenInput1);
    delForm.submit();
  }
</script>